﻿<%@ Page Title="" Language="C#" MasterPageFile="~/WorkstationHost.Master" AutoEventWireup="true"
    CodeBehind="ContentDevice.aspx.cs" Inherits="WorkstationDashboard.ContentDevice" %>

<%@ MasterType VirtualPath="~/WorkstationHost.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">

        var processingDlg;
        var processingMsg;
        var headerMessage;
        var deviceId;

        $(document).ready(function () {
            processingDlg = $("#processingDlg");
            processingMsg = $("#processingMsg");
            headerMessage = $("#headerMessage");
            deviceId = $("#<%=deviceId.ClientID %>").val();
        });

        function removeDevice() {
            if (confirm("Are you sure to remove this Device? The related battery logs will be removed as well")) {

                processingDlg.dialog("open");
                processingMsg.html("Removing Device...");

                PageMethods.RemoveDevice(deviceId, onRemoveSucceed, onRemoveFail);
            }
        }

        function onRemoveFail(error) {
            var errorMsg = error.get_message();
            processingMsg.addClass("ui-state-error");
            processingMsg.html(errorMsg);
        }

        function onRemoveSucceed() {
            processingMsg.html("Device is removed");
            setTimeout(function () {
                processingDlg.dialog("close");
                location.href = "ContentRoot.aspx";
            }, 2000);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="ui-helper-hidden">
        <asp:HiddenField ID="deviceId" runat="server"></asp:HiddenField>
    </div>
    <div>
        <div id="processingDlg">
            <div id="processingMsg" class="ui-state-default">
            </div>
        </div>
        <script type="text/javascript">
            $("#processingDlg").dialog({ autoOpen: false, modal: true });
        </script>
    </div>
    <div class="ui-layout-center" style="display: none">
        <div id="headerMessage" runat="server">
        </div>
        <div>
            <h2>
                Battery -
                <asp:Label ID="batteryName" runat="server"></asp:Label>
            </h2>
        </div>
        <div>
            <div>
                Battery Type:
                <asp:Label ID="batteryType" runat="server"></asp:Label></div>
            <div>
                <%--Battery Version:--%>
                <asp:Label ID="batteryVersion" runat="server"></asp:Label></div>
            <div>
                Power Level:
                <asp:Label ID="powerLevel" runat="server"></asp:Label>%</div>
            <div>
                Is connected:
                <asp:Label ID="isConnected" runat="server"></asp:Label></div>
            <div>
                Last connected time:
                <asp:Label ID="lastConnectedTime" runat="server"></asp:Label></div>
                <div>
Temperature: 
                <asp:Label ID="temperature" runat="server"></asp:Label></div>

        </div>
    </div>
    <div class="ui-layout-east" style="display: none">
        <h3>
            Tasks
        </h3>
        <div>
            <div>
                <input id="removeButton" type="button" onclick="removeDevice()" value="Remove Device" />
            </div>
        </div>
    </div>
</asp:Content>
